#include <iostream>
#include <functional>
#include <unistd.h>
#include <signal.h>
#include<vector>
using func_t = std::function<void()>;
std::vector<func_t> f_uion;
int gcount = 0;
void handle(int signo)
{
  for (auto &f : f_uion)
  {
    f();
  }

  std::cout << signo << std::endl;
  std::cout << gcount << std::endl;

  alarm(2);
}
int main()
{
  f_uion.push_back([]()
                   { std::cout << "我是下载任务" << std::endl; });
  f_uion.push_back([]()
                   { std::cout << "我是上传任务任务" << std::endl; });
  f_uion.push_back([]()
                   { std::cout << "我是更新任务" << std::endl; });
  alarm(2);
  signal(SIGALRM, handle);
  while (true)
  {
    pause();
    std::cout << "我醒来了..." << std::endl;
    gcount++;
  }
  return 0;
}
